import os

from selenium.webdriver.support.wait import WebDriverWait


class BaseAction:
    def __init__(self, driver):
        self.driver = driver

    # 1.封装获取元素[显示等待+判断有没有找到元素]
    def get_element(self, fixture):
        wait = WebDriverWait(self.driver, 10000, 2)
        try:
            ele = wait.until(lambda x: x.find_element(*fixture))
        except Exception:
            print(f"找不到元素{fixture}")
            return None
        else:
            return ele


def get_path():
    # base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    base_dir = os.path.dirname(os.path.abspath(__file__))
    return base_dir


